// src/api/api.ts
import request from "@/utils/request";

/**
 * 获取角色列表
 * @param params '角色列表'
 * @returns
 */
export const getRoleListApi = (params: any) => {
  return request({
    url: "/api/role/list",
    method: "GET",
    params: params,
  });
};

/**
 * 删除角色
 * @param id '角色id'
 * @returns
 */
export const deleteRoleApi = (id: number) => {
  return request({
    url: `/api/role/delete/${id}`,
    method: "DELETE",
  });
};

/**
 * 添加角色
 * @param data '角色数据'
 * @returns
 */
export const addRoleApi = (data: any) => {
  return request({
    url: "/api/role/saveOrUpdate",
    method: "POST",
    data: data,
  });
};

/**
 * 根据id获取角色权限
 * @param id
 * @returns
 */
export const getRoleAuthorityApi = (id: number) => {
  return request({
    url: `/api/permission/queryPermission/${id}`,
    method: "GET",
  });
};

/**
 * 获取全部权限
 * @param data
 * @returns
 */
export const getAllPermissionApi = (params: any) => {
  return request({
    url: "/api/permission/list",
    method: "GET",
    params: params,
  });
};

/**
 * 根据id获取角色菜单
 * @param id
 * @returns
 */
export const getRoleMenuListApi = (id: number) => {
  return request({
    url: `/api/menu/getMenuRoleById/${id}`,
    method: "GET",
  });
};
